#include <bits/stdc++.h>

using namespace std;

class StockPrice {
public:
	void update(int timestamp, int price)
	{
		if (timestamp >= lastest.first) {
			lastest.first = timestamp;
			lastest.second = price;
		}
		auto old = min_max.find(time2val[timestamp]);
		time2val[timestamp] = price;
		if (old != end(min_max)) {
			if (old->second == 1)
				min_max.erase(old);
			else
				--old->second;
		}
		min_max[price]++;
	}

	int current()
	{
		return lastest.second;
	}

	int maximum()
	{
		return rbegin(min_max)->first;
	}

	int minimum()
	{
		return begin(min_max)->first;
	}

private:
	pair<int, int> lastest;
	map<int, int> min_max;
	unordered_map<int, int> time2val;
};

/**
 * Your StockPrice object will be instantiated and called as such:
 * StockPrice* obj = new StockPrice();
 * obj->update(timestamp,price);
 * int param_2 = obj->current();
 * int param_3 = obj->maximum();
 * int param_4 = obj->minimum();
 */
;

int main()
{
	return 0;
}
